#include <iostream>
#include <string>

using namespace std;

template <class Type>
Type bubbleSort(Type *array, int arraySize);

int main()
{
	int arraySize;
	cout << "Enter the size of the integer array you want to create" << endl;
	cin >> arraySize;

	int integerArrayToBeSorted[arraySize];
	cout << "Enter the integer array values" << endl;
	for(int i=0; i<arraySize;i++)
	{
		cout << "array[" << i << "]";
		cin >> integerArrayToBeSorted[i];
	}

	cout << "The unsorted integer array is" << endl;
	for(int i = 0; i<arraySize;i++)
	{
		cout << integerArrayToBeSorted[i] << endl;
	}

	bubbleSort(integerArrayToBeSorted, arraySize);

	cout << "The sorted integer array is" << endl;
	for(int i = 0; i<arraySize;i++)
	{
		cout << integerArrayToBeSorted[i] << endl;
	}

	//double array
	cout << "Enter the size of the double array you want to create" << endl;
	cin >> arraySize;

	double doubleArrayToBeSorted[arraySize];
	cout << "Enter the double array values" << endl;
	for(int i=0; i<arraySize;i++)
	{
		cout << "array[" << i << "]";
		cin >> doubleArrayToBeSorted[i];
	}

	cout << "The unsorted double array is" << endl;
	for(int i = 0; i<arraySize;i++)
	{
		cout << doubleArrayToBeSorted[i] << endl;
	}

	bubbleSort(doubleArrayToBeSorted, arraySize);

	cout << "The sorted double array is" << endl;
	for(int i = 0; i<arraySize;i++)
	{
		cout << doubleArrayToBeSorted[i] << endl;
	}
	return 0;
}

template <class Type>
Type bubbleSort(Type *array, int arraySize)
{
	for(int i = 0; i < (arraySize-1) ; i++)
	{
		for(int j = 0; j < (arraySize-1); j++)
		{
			if(array[j] > array[j+1])
			{
				Type temp = array[j];
				array[j] = array[j+1];
				array[j+1] = temp;
			}
		}
	}
}
